<%@page import="cfs.databean.Fund"%>
<jsp:include page="tempHeader.jsp" />
<jsp:include page="tempMenubar.jsp" />
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="cfs.databean.Customer" %>
<jsp:include page="fundChart.jsp" />
<div id="container">
    <div id="content" class="wrap">  
         <div class="marginBottom30 clearFix">
          <hr><h2 class="separate">${fund.name}  (${fund.symbol})</h2>
          <div class="col1-3">
          <h3> Latest Fund Price: </h3><p> &#36;${latestPrice}</p>
          <h3> Fund Price Difference: </h3><p> ${fundPriceDiff}</p>
          <h3> Fund Volatility: </h3><p> ${volatility}</p>
          <h3> Maximum Price over last 7 trade days:</h3><p> &#36;${maxPrice}</p>
          <h3 > Minimum Price over last 7 trade days:</h3><p> &#36;${minPrice}</p>
          </div>
          <%
                   if(request.getSession().getAttribute("user") != null){
                                    
          %>
          <hr><div class="col1-3">
              <h3>Ledger Share Holdings</h3>   
              <p>${userShare}</p>
              <h3>Available Shares</h3>   
              <p>${userAvaShare}</p>
              <h3>User Total Invested Amount Since Inception:</h3>   
              <p>&#36;${investedAmount}</p>
              <h3>User Total Cash Received Since Inception :</h3>   
              <p>&#36;${totalProfit}</p>
              <h3>Current Holding Value:</h3>   
              <p>&#36;${retrieveTotalEarnings}</p>
              <p></p>
          </div>
         </div>
         <div class="marginBottom30 clearFix">
          <div class="col1-3" >
              <h3 class="separate">Available Actions for User</h3>
                 <div id="contact_form">
                    <form  action="buyFund.do" method="post">
                           <input type="hidden" name="symbol" value="${fund.symbol}" id="symbol" />
                           <input type="submit" class="submit_btn2" name="submit" id="submit" value="Buy Fund" />
                    </form>
                 </div>
                <div id="contact_form">
                    <form method="post" action="sellFund.do">
                           <input type="submit" class="submit_btn2" name="submit" id="submit" value="Sell Fund" />
                    </form>
                 </div>
          </div>
          <%}
          %>
          </div>
          <h3 class="separate"></h3>
          <h3>Past Week Closing Price:</h3>              
          <table>
              <c:if test="${!empty fundHistoryList }">
                  <tr >
                  <c:forEach var="entry" items="${fundHistoryList }">
                      <c:if test="${empty entry.price_date }">
                        <th class="amount header" width ="150" style="text-align:right;">Not Initiated</th>
                      </c:if>
                        <c:if test="${! empty entry.price_date }">
                       <th class="amount header" width ="150" style="text-align:right;">${entry.price_date }</th>
                        </c:if>
                  </c:forEach>
                  </tr>
                  <tr>
                  <c:forEach var="entry" items="${fundHistoryList }">
                            <th style="text-align: right;">&#36;${entry.price / 100}</th>
                  </c:forEach>
                  </tr>
              </c:if>
          </table>
          <h3 class="separate"></h3>
          <h2 class="separate">Fund Chart</h2>
          <div id="container2" class="chartBox"></div>
          <h3 class="separate"></h3>
          <p><jsp:include page="error-list.jsp" /></p>
          <p><a href="allFundHistory.do?selectedFund=${fund.fund_id}"><i>View All Fund Price History</i></a></p>
    </div>
          
   
</div>
<jsp:include page="tempBottom.jsp" />